package com.yayako.modules.user.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yayako.modules.department.entity.Department;
import com.yayako.utils.EasyExcel.CustomConverter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;

/** @author cyy */
public class User implements UserDetails {
  private static final long serialVersionUID = -2807904579882613200L;
  private String id;

  @ExcelProperty(value = "用户名", index = 0)
  private String username;

  private String password;

  @ExcelProperty(value = "性别", index = 1)
  private String gender;

  @ExcelProperty(value = "生日", index = 2)
  @DateTimeFormat("YYYY-MM-DD")
  private Date birthday;

  @ExcelProperty(value = "所在部门", index = 3, converter = CustomConverter.class)
  private Department dept;

  private String roleId;
  @JsonIgnore private Boolean isAccountNonExpired;
  @JsonIgnore private Boolean isAccountNonLocked;
  @JsonIgnore private Boolean isCredentialsNonExpired;
  @JsonIgnore private Boolean isEnabled;

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id == null ? null : id.trim();
  }

  @Override
  public String getUsername() {
    return username;
  }

  public void setUsername(String username) {
    this.username = username == null ? null : username.trim();
  }

  @Override
  public boolean isAccountNonExpired() {
    return isAccountNonExpired;
  }

  public void setAccountNonExpired(Boolean accountNonExpired) {
    isAccountNonExpired = accountNonExpired;
  }

  @Override
  public boolean isAccountNonLocked() {
    return isAccountNonLocked;
  }

  public void setAccountNonLocked(Boolean accountNonLocked) {
    isAccountNonLocked = accountNonLocked;
  }

  @Override
  public boolean isCredentialsNonExpired() {
    return isCredentialsNonExpired;
  }

  public void setCredentialsNonExpired(Boolean credentialsNonExpired) {
    isCredentialsNonExpired = credentialsNonExpired;
  }

  @Override
  public boolean isEnabled() {
    return isEnabled;
  }

  public void setEnabled(Boolean enabled) {
    isEnabled = enabled;
  }

  @Override
  public Collection<? extends GrantedAuthority> getAuthorities() {
    return null;
  }

  @Override
  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password == null ? null : password.trim();
  }

  public String getGender() {
    return gender;
  }

  public void setGender(String gender) {
    this.gender = gender == null ? null : gender.trim();
  }

  public Date getBirthday() {
    return birthday;
  }

  public void setBirthday(Date birthday) {
    this.birthday = birthday;
  }

  public Department getDept() {
    return dept;
  }

  public void setDept(Department dept) {
    this.dept = dept;
  }

  public String getRoleId() {
    return roleId;
  }

  public void setRoleId(String roleId) {
    this.roleId = roleId == null ? null : roleId.trim();
  }
}
